package com.ly.user_system.retry;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.retry.policy.CircuitBreakerRetryPolicy;
import org.springframework.retry.support.RetryTemplate;

import java.time.Duration;

@Configuration
public class RetryConfig {


    @Bean
    public RetryTemplate retryTemplate(){
        CircuitBreakerRetryPolicy circuitBreakerRetryPolicy = new CircuitBreakerRetryPolicy();
        return RetryTemplate.builder()
                .customPolicy(circuitBreakerRetryPolicy)
                .exponentialBackoff(Duration.ofMillis(500), 2, Duration.ofSeconds(3), true)
                .build();
    }

}
